# Maintainer: Brendan Forster <brendan@github.com>

_realname="git-lfs"
pkgbase="mingw-w64-${_realname}"
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.7.1
pkgrel=1
pkgdesc="An open source Git extension for versioning large files"
install=git-lfs.install
arch=('any')
url="https://github.com/git-lfs/git-lfs"
src_zip_url="${url}/archive/v${pkgver}.zip"
license=('MIT')
groups=('VCS')

case "$CARCH" in
i686)
  zipname="git-lfs-windows-386-v$pkgver.zip"
  folder=git-lfs-$pkgver/
  sha256sum=06c05c06523abf3930301b3022527ad881b1a7f8bf036ed6d93c8e68569041bb
  exesuffix=
  ;;
x86_64)
  zipname="git-lfs-windows-amd64-v$pkgver.zip"
  folder=git-lfs-$pkgver/
  sha256sum=8683cdc3d6c029b49393dcebbaa6265bd6efd9abdcf837be855b4cd42e5e80b6
  exesuffix=
  ;;
aarch64)
  zipname="git-lfs-windows-arm64-v$pkgver.zip"
  folder=git-lfs-$pkgver/
  sha256sum=9441383a3928a7f387223711929292a46ace95580ceed443d61e7b8a4d9615c3
  exesuffix=
  ;;
esac

source=("https://github.com/github/git-lfs/releases/download/v$pkgver/$zipname"
	"$src_zip_url")

# Git LFS' source .zip now contains symbolic links that bsdtar does not like...
noextract=("${src_zip_url##*/}")

sha256sums=("$sha256sum" SKIP)
options=('!strip')

package() {
  install -d -m755 $pkgdir/$MINGW_PREFIX/bin
  install -m755 $srcdir/$folder/git-lfs$exesuffix.exe $pkgdir/$MINGW_PREFIX/bin/git-lfs.exe
  install -d -m755 $pkgdir/$MINGW_PREFIX/share/doc/git-lfs
  install -m755 $srcdir/$folder/README.md $pkgdir/$MINGW_PREFIX/share/doc/git-lfs/README.md
  install -d -m755 $pkgdir/$MINGW_PREFIX/share/doc/git-doc
  for f in $srcdir/$folder/man/html/git-lfs*.1.html
  do
    ff=${f##*/}
    install -m755 $f $pkgdir/$MINGW_PREFIX/share/doc/git-doc/${ff%.1.html}.html
  done
}
